﻿#include "serialportset.h"
#include "ui_serialportset.h"

serialportset::serialportset(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::serialportset)
{
    ui->setupUi(this);
    QStringList ports;

    ports << "9600" << "115200";

    ui->ck_port->addItems(ports);
}

serialportset::~serialportset()
{
    delete ui;
}

void serialportset::setUartInfoList(QList<QSerialPortInfo> portInfoList)
{
    for(int idx = 0; idx < portInfoList.size(); idx++)
    {
        ui->ck_uart->addItem(portInfoList.at(idx).portName());
    }
}

void serialportset::on_btn_ok_clicked()
{
    emit selectPort(ui->ck_uart->currentIndex(), ui->ck_port->currentText().toInt());
    this->close();
}
